How to build a local Terraform Pagerduty Provider

We have no access to git clone so I am wanting to build a local provider and use that.
I am hitting a brick wall in trying to understand how to do this.
I downloaded the code from:
https://github.com/PagerDuty/terraform-provider-pagerduty/archive/refs/heads/master.zip
Any ideas?

Hello @tariq.hasan. You’ll find the instructions to build the Terraform provider locally in the repo:

Instead of the git clone command, you’ll unzip your downloaded file into the directory under your $GOPATH

unzip terraform-provider-pagerduty-master.zip

Then you should be able to build locally with
make build

HI Mandi
Thanks for your response.
I’m running this from my windows machine
So my %GOPATH% is:
C:\Users\thasan>echo %GOPATH%
C:\Users\thasan\go
go
I have copied the unzipped folder into C:\Users\thasan

C:\Users\thasan>dir terraform-provider-pagerduty-master
Volume in drive C is Windows
Volume Serial Number is 5233-F339

Directory of C:\Users\thasan\terraform-provider-pagerduty-master

17/08/2023 12:28 .
17/08/2023 12:28 …
17/08/2023 12:29 terraform-provider-pagerduty-master
0 File(s) 0 bytes
3 Dir(s) 88,230,903,808 bytes free

What is the command to do the “make build” in windows?

Thanks & Regards

I’ve tried using linux now, and here are my issues:

[root@-001 pagerduty]# echo $GOPATH

no GOPATH

[root@-001 pagerduty]# go version
go version go1.19.10 linux/amd64

Tried the “make build” - got this:

[root@-001 pagerduty]# make build
make: *** No rule to make target `build’. Stop.

This is my new GOPATH

[root@-001 go]# echo $GOPATH
/usr/local/bin/go

So I unzipped the file into /usr/local/bin/go
Set the GOPATH on the .bash_profile

and now the make errors

[root@-001 terraform-provider-pagerduty-master]# make build
==> Checking that code complies with gofmt requirements…
go install -tags timetzdata

Looking healthier, thanks a lot.

Hi @tariq.hasan from this point on you should be ready to go, right?

A very importante step to test your local build is to set up the PagerDuty Terraform Provider override, so when you try to use the provider locally, your local version will be the one in use.

Instructions here :point_left:

@josé.antonio.reyes @mandi.walls
You both have been a great help, thanks. I know have a basic structure of Business Service creation.
Now I’m struggling a little.
I need to create a new Tech Svs using TF, but need to assign an Esc Policy that already exists in PD that wasn’t crated using TF.

I have this code:

data “pagerduty_escalation_policy” “FG-CDO-Platform-Escalation-Policy” {
name = “FG-CDO-Platform-Escalation-Policy” # Replace with the name of the escalation policy you want to retrieve
}

output “escalation_policy_details” {
value = data.pagerduty_escalation_policy.FG-CDO-Platform-Escalation-Policy
}

But don’t know how to use it in this code:

resource “pagerduty_service” “SNP_IBOX_Pipeline_Workflow” {
name = “SNP_IBOX Pipeline Workflow”
description = “SNP_IBOX Pipeline Workflow.”
escalation_policy = pagerduty_escalation_policy.FG-CDO-Platform-Escalation-Policy.id
type = “technical”
}

Hi @tariq.hasan you’re almost there, what you need to do is referring to the Escalation Policy data source in your Service configuration prefixing the Data Source with data.pagerduty_escalation_policy.FD-CDO-Platform-Escalation-Policy, however to be more explicit, It would be like this…

resource "pagerduty_service" "SNP_IBOX_Pipeline_Workflow" {
  name              = "SNP_IBOX Pipeline Workflow"
  description       = "SNP_IBOX Pipeline Workflow."
  escalation_policy = data.pagerduty_escalation_policy.FG-CDO-Platform-Escalation-Policy.id
  type              = "technical"
}

Excellent, learning something new all the time with your help, many thanks @josé.antonio.reyes and @mandi.walls

2 Likes